package cn.funnyxb.powerremember.uis.task.taskEdit;

import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import cn.funnyxb.powerremember.beans.AlarmInfo;
import cn.funnyxb.tools.appFrame.debugTool.Debuger;
import java.util.ArrayList;

public class Adapter_TaskEdit_Alarms extends BaseAdapter
{
  private Context context;
  private LayoutInflater layoutInflater;
  private ArrayList<AlarmInfo> list;
  private int[] oldAlarmIds = null;

  public Adapter_TaskEdit_Alarms(Context paramContext, Cursor paramCursor)
  {
    log("load from cursor!");
    this.context = paramContext;
    this.list = new ArrayList();
    this.layoutInflater = ((LayoutInflater)paramContext.getSystemService("layout_inflater"));
    if ((paramCursor == null) || (paramCursor.getCount() <= 0))
      return;
    paramCursor.moveToFirst();
    this.oldAlarmIds = new int[paramCursor.getCount()];
    int j;
    for (int i = 0; ; i = j)
    {
      if (!(paramCursor.isAfterLast()));
      AlarmInfo localAlarmInfo = AlarmInfo.parseFromCursor(paramCursor);
      int[] arrayOfInt = this.oldAlarmIds;
      j = i + 1;
      arrayOfInt[i] = localAlarmInfo.get_id();
      this.list.add(localAlarmInfo);
      paramCursor.moveToNext();
    }
  }

  public Adapter_TaskEdit_Alarms(Context paramContext, ArrayList<AlarmInfo> paramArrayList)
  {
    this.context = paramContext;
    this.list = paramArrayList;
    this.layoutInflater = ((LayoutInflater)paramContext.getSystemService("layout_inflater"));
    log("oncreate ,size=" + this.list.size());
  }

  private void checkChange(CompoundButton paramCompoundButton)
  {
    int i = ((Integer)paramCompoundButton.getTag()).intValue();
    ((AlarmInfo)this.list.get(i)).setEnabled(paramCompoundButton.isChecked());
    StringBuilder localStringBuilder = new StringBuilder(String.valueOf(this.context.getString(2131034160))).append(i + 1).append(this.context.getString(2131034251));
    if (paramCompoundButton.isChecked());
    for (String str = "(" + this.context.getString(2131034252) + ")"; ; str = "(" + this.context.getString(2131034253) + ")")
    {
      paramCompoundButton.setText(str);
      return;
    }
  }

  private void freashItemview(View paramView, int paramInt)
  {
    AlarmInfo localAlarmInfo = (AlarmInfo)this.list.get(paramInt);
    ((CheckBox)paramView.findViewById(2131165302)).setTag(Integer.valueOf(paramInt));
    ((CheckBox)paramView.findViewById(2131165302)).setChecked(localAlarmInfo.isEnabled());
    ((TextView)paramView.findViewById(2131165303)).setText(localAlarmInfo.phraseTime2Str());
    ((TextView)paramView.findViewById(2131165304)).setText(this.context.getString(2131034254) + ": " + localAlarmInfo.getRepeatText(this.context));
    TextView localTextView1 = (TextView)paramView.findViewById(2131165305);
    String str1;
    label182: String str2;
    String str3;
    label300: CheckBox localCheckBox;
    StringBuilder localStringBuilder2;
    if (localAlarmInfo.isWorkOnlyWhenDelay())
    {
      str1 = this.context.getString(2131034257) + ": " + this.context.getString(2131034258);
      localTextView1.setText(str1);
      ((TextView)paramView.findViewById(2131165306)).setText(this.context.getString(2131034255) + ": " + localAlarmInfo.getAlarmTypeText(this.context));
      str2 = localAlarmInfo.getMemo();
      TextView localTextView2 = (TextView)paramView.findViewById(2131165307);
      StringBuilder localStringBuilder1 = new StringBuilder(String.valueOf(this.context.getString(2131034256))).append(": ");
      if (!(localAlarmInfo.isRandomOil()))
        break label463;
      str3 = this.context.getString(2131034260);
      localTextView2.setText(str3);
      localCheckBox = (CheckBox)paramView.findViewById(2131165302);
      localStringBuilder2 = new StringBuilder(String.valueOf(this.context.getString(2131034160))).append(paramInt + 1).append(this.context.getString(2131034251));
      if (!(localAlarmInfo.isEnabled()))
        break label470;
    }
    for (String str4 = "(" + this.context.getString(2131034252) + ")"; ; str4 = "(" + this.context.getString(2131034253) + ")")
    {
      localCheckBox.setText(str4);
      return;
      str1 = this.context.getString(2131034257) + ": " + this.context.getString(2131034259);
      break label182:
      label463: str3 = str2;
      label470: break label300:
    }
  }

  private void log(String paramString)
  {
    Debuger.log("adapter_alarms", paramString);
  }

  public void addItem(AlarmInfo paramAlarmInfo)
  {
    this.list.add(paramAlarmInfo);
    log("after add list size=" + this.list.size());
    notifyDataSetChanged();
  }

  public AlarmInfo delItem(int paramInt)
  {
    AlarmInfo localAlarmInfo = (AlarmInfo)this.list.get(paramInt);
    this.list.remove(paramInt);
    notifyDataSetChanged();
    return localAlarmInfo;
  }

  public void editItem(int paramInt, AlarmInfo paramAlarmInfo)
  {
    ((AlarmInfo)this.list.get(paramInt)).setValue(paramAlarmInfo);
    notifyDataSetChanged();
  }

  public ArrayList<AlarmInfo> getAllAlarms()
  {
    log("getalloflist size=" + this.list.size());
    return this.list;
  }

  public int getCount()
  {
    return this.list.size();
  }

  public AlarmInfo getItem(int paramInt)
  {
    return ((AlarmInfo)this.list.get(paramInt));
  }

  public long getItemId(int paramInt)
  {
    return paramInt;
  }

  public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
  {
    log("getView,po=" + paramInt);
    if (paramInt >= this.list.size());
    for (View localView = null; ; localView = paramView)
    {
      return localView;
      if (paramView == null)
      {
        paramView = this.layoutInflater.inflate(2130903053, null);
        ((CheckBox)paramView.findViewById(2131165302)).setOnCheckedChangeListener(new 1(this));
      }
      freashItemview(paramView, paramInt);
    }
  }
}

/* Location:           E:\Desktop\复件 classes_dex2jar.jar
 * Qualified Name:     cn.funnyxb.powerremember.uis.task.taskEdit.Adapter_TaskEdit_Alarms
 * JD-Core Version:    0.5.3
 */